<template>
  <div id="map-container" class="map-container">
    <transition name="el-zoom-in-top">
      <template v-if="xianZhuangPath">
        <div v-show="mapIframeVisible" class="map-iframe">
          <div class="shenchaButton">
            <el-button size="mini" @click="closeMapIframe">关闭</el-button>
          </div>

          <div v-loading="loadingIframe" style="width: 100%; height: 100%;">
            <iframe
              id="mapIframe"
              :src="$httpsCad + '/?url=' + $https + xianZhuangPath"
              frameborder="0"
              style="width: 100%; height: 100%;"
            />
          </div>
        </div>
      </template>
    </transition>
    <l-map
      ref="map"
      class="map-right"
      style="height: 100%"
      :zoom="mapBaseConfig.zoom"
      :center="mapBaseConfig.center"
      :min-zoom="mapBaseConfig.minZoom"
      :max-zoom="mapBaseConfig.maxZoom"
      :crs="mapCrs"
      :options="mapOptions"
    >
      <div v-show="isShowControls != false">
        <l-tile-layer v-if="mapMode == 'sl'" :url="mapLayers.cqVec.tileUrl" />
        <l-layer-group v-if="mapMode == 'yx'">
          <l-tile-layer :url="mapLayers.cqImg.tileUrl" />
          <l-tile-layer :url="mapLayers.cqMark.tileUrl" />
        </l-layer-group>
      </div>

      <l-tile-layer v-for="(value, key, index) in treeCheckedObj" :key="key" :url="value.tileUrl" />

      <l-feature-group ref="features">
        <l-popup class="tdMap-popup-box" :options="{ minWidth: 760 }">
          <div class="pk-popup-box">
            <div class="left" />
            <div class="right">
              <div
                class="pk-popup-title"
              >{{ baseInfoData ? baseInfoData.pkh || baseInfoData.pkm || baseInfoData.landName : '' }}</div>
            </div>
          </div>
          <el-tabs v-model="popupActiveName" class="pk-popup-tabs" tab-position="left">
            <el-tab-pane label="基本信息" name="jbxx">
              <div class="base-info jbxx setScroll">
                <slot name="popupBaseInfo" />
              </div>
            </el-tab-pane>
            <el-tab-pane label="综合监管" name="zhjg">
              <div class="base-info jgxx setScroll">
                <slot name="popupJgInfo" />
              </div>
            </el-tab-pane>
            <el-tab-pane label="审查意见" name="scyj">
              <div v-if="popupActiveName == 'scyj'" class="base-info scyj setScroll">
                <!-- <slot name="popupScyjInfo" /> -->
                <AuditOpinion
                  :current-pk-data="currentPkData"
                  :is-look="isLook"
                  :layer-name="layerName"
                  :link-value="linkValue"
                  :fs-link-value="fsLinkValue"
                  :show-fs="showFs"
                  :init-active-name="initActiveName"
                />
              </div>
            </el-tab-pane>
            <el-tab-pane v-if="showSjsc" label="审定意见" name="sjsc">
              <div class="base-info sjsc setScroll">
                <slot name="popupSjscInfo" />
              </div>
            </el-tab-pane>
          </el-tabs>
        </l-popup>
      </l-feature-group>

      <l-geo-json
        v-for="(item, index) in pkList"
        :key="index"
        ref="geoJson"
        :geojson="item.feature"
        :options-style="polygonStyleMap.defaultStyle"
        @click="handleClickPolygon($event, item, index)"
      />
    </l-map>

    <!-- 地图模式切换 s -->
    <div v-show="isShowControls != false" class="map-mode">
      <div class="map-mode-item sl" @click.stop="changeMapMode('sl')">
        <div class="text">矢量</div>
      </div>
      <div class="map-mode-item yx" @click.stop="changeMapMode('yx')">
        <div class="text">影像</div>
      </div>
    </div>
    <!-- 地图模式切换 e -->

    <!-- 地图工具栏 s -->
    <div v-show="isShowControls != false" class="map-tools">
      <div
        title="图层"
        :class="{ 'map-tools-item line': true, active: toolsValue.layer }"
        @click="handleToolsSwitch('layer')"
      >
        <svg-icon
          class="svg-icon"
          :icon-class="!toolsValue.layer ? 'chy-icon-nav' : 'chy-icon-nav-active'"
        />
        <!-- <i class="chy-icon-nav"></i> -->
      </div>

      <div
        id="lineMeasure"
        title="测距"
        :class="{ 'map-tools-item line': true, active: toolsValue.ruler }"
        @click="handleToolsSwitch('ruler')"
      >
        <svg-icon
          class="svg-icon"
          :icon-class="!toolsValue.ruler ? 'chy-icon-celiang' : 'chy-icon-celiang-active'"
        />
        <!-- <i class="chy-icon-celiang"></i> -->
      </div>

      <div
        id="areaMeasure"
        title="面积测量"
        :class="{ 'map-tools-item line': true, active: toolsValue.area }"
        @click="handleToolsSwitch('area')"
      >
        <svg-icon
          class="svg-icon"
          :icon-class="!toolsValue.area ? 'chy-icon-mianji' : 'chy-icon-mianji-active'"
        />
        <!-- <i class="chy-icon-mianji"></i> -->
      </div>

      <div
        title="卷帘对比"
        :class="{ 'map-tools-item line': true, active: toolsValue.cut }"
        @click="openSideBySidePopup"
      >
        <svg-icon
          class="svg-icon"
          :icon-class="!toolsValue.cut ? 'chy-icon-juanlian' : 'chy-icon-juanlian-active'"
        />
        <!-- <i class="chy-icon-juanlian"></i> -->
      </div>

      <div id="browserPrint" class="map-tools-item line" title="打印">
        <svg-icon class="svg-icon" icon-class="chy-icon-dayin" />
        <!-- <i class="chy-icon-dayin"></i> -->
      </div>

      <div
        :title="isFullScreen == true ? '退出全屏' : '全屏'"
        class="map-tools-item line"
        @click.stop="handleFullScreen"
      >
        <!-- <i :class="isFullScreen == true ? 'chy-icon-tuichuquanping' : 'chy-icon-quanping'"></i> -->
        <svg-icon class="svg-icon" icon-class="chy-icon-quanping" />
        <!-- <i class="chy-icon-quanping"></i> -->
      </div>

      <div class="map-tools-item line" title="清除测距、面积测量" @click.stop="handleClear">
        <svg-icon class="svg-icon" icon-class="chy-icon-qingchu" />
        <!-- <i class="chy-icon-qingchu"></i> -->
      </div>
    </div>
    <!-- 地图工具栏 e -->

    <!-- 地图图层 s -->
    <transition name="el-zoom-in-top">
      <div v-show="toolsValue.layer" class="map-layer">
        <el-collapse v-model="collapseValue">
          <el-collapse-item v-for="(item, index) in treeData" :key="index" name="1">
            <template slot="title">
              <div class="map-layer-title">{{ item.label }}</div>
            </template>
            <div class="map-layer-content">
              <div
                v-for="(item2, index2) in item.children"
                :key="index2"
                :class="{
                  'map-layer-content-item': true,
                  active: item2.isChecked
                }"
                @click="handleTreeCheck(item2)"
              >{{ item2.label }}</div>
            </div>
          </el-collapse-item>
        </el-collapse>
      </div>
    </transition>
    <!-- 地图图层 e -->

    <!-- 片块搜索区域 s -->
    <div v-show="isShowControls != false" class="map-search">
      <el-autocomplete
        v-model="searchValue"
        clearable
        class="map-search-input"
        suffix-icon="el-icon-search"
        placeholder="搜索片块号"
        :fetch-suggestions="handlePkSearch"
        @clear="handleAutocompleteClear"
        @select="handleMapSearchSelect"
      />
      <el-button-group v-show="currentPkData != null" class="buttonGroupClass">
        <slot v-show="isShowXztBtn != false" name="buttonGroup" />

        <!-- <el-dropdown @command="handleScView">
          <el-button class="line" size="medium">
            审查意见
            <i class="el-icon-arrow-down el-icon--right" />
          </el-button>
          <el-dropdown-menu slot="dropdown">
            <el-dropdown-item v-show="isShowScyjBtn != false" command="0">内业审查意见</el-dropdown-item>
            <el-dropdown-item v-show="isShowScWyBtn != false" command="1">外业审查意见</el-dropdown-item>
          </el-dropdown-menu>
        </el-dropdown>-->
      </el-button-group>
    </div>
    <!-- 片块搜索区域 e -->

    <el-dialog :close-on-click-modal="false" :visible.sync="dialogVisible">
      <img width="100%" :src="dialogImageUrl" />
    </el-dialog>

    <el-dialog
      class="side-by-side-popup"
      title="选择卷帘对比的图层"
      :close-on-click-modal="false"
      :visible.sync="sideBySidePopup"
    >
      <el-row :gutter="20">
        <el-col :span="12">
          <el-card header="左侧图层">
            <el-tree
              ref="leftTree"
              default-expand-all
              :data="treeData"
              :expand-on-click-node="false"
              :highlight-current="true"
              :props="defaultProps"
              @node-click="handleSideBySideClick($event, 'left')"
            />
          </el-card>
        </el-col>
        <el-col :span="12">
          <el-card header="右侧图层">
            <el-tree
              ref="rightTree"
              default-expand-all
              :data="treeData"
              :expand-on-click-node="false"
              :highlight-current="true"
              :props="defaultProps"
              @node-click="handleSideBySideClick($event, 'right')"
            />
          </el-card>
        </el-col>
      </el-row>
      <el-row>
        <el-button class="confirm-btn" @click="handleSideBySide">确定选择</el-button>
      </el-row>
    </el-dialog>
  </div>
</template>

<script>
// var L = require('@/lib/leaflet/leaflet')
import 'proj4leaflet/lib/proj4-compressed.js'
import 'proj4leaflet/src/proj4leaflet.js'

import {
  LMap,
  LTileLayer,
  LPopup,
  LLayerGroup,
  LGeoJson,
  LFeatureGroup
} from 'vue2-leaflet'

import 'leaflet/dist/leaflet.css'
import '@/icons/iconfont.css'
import 'leaflet.browser.print/dist/leaflet.browser.print'

// import icon from 'leaflet/dist/images/marker-icon.png'
// import iconShadow from 'leaflet/dist/images/marker-shadow.png'

// const DefaultIcon = L.icon({
//   iconUrl: icon,
//   shadowUrl: iconShadow
// })
// L.Marker.prototype.options.icon = DefaultIcon

import '@/lib/leaflet/control.css'
import '@/lib/leaflet/control.js'

import { QScreenSwitcher } from '@/utils/common.js'
import { verify_drawings_opinion } from '@/api/common.js'

import AuditOpinion from './components/auditOpinion'

var esri = require('esri-leaflet')

export default {
  name: 'TdMap',
  components: {
    LMap,
    LTileLayer,
    LPopup,
    LLayerGroup,
    LGeoJson,
    LFeatureGroup,
    AuditOpinion
  },
  props: [
    'pkList',
    'isShowControls',
    'isShowScyjBtn',
    'isShowScWyBtn',
    'isShowXztBtn',
    'xianZhuangPath',
    'zhjgList',
    'isLook',
    'showSjsc',
    'layerName',
    'linkValue',
    'fsLinkValue',
    'showFs',
    'initActiveName'
  ],
  data() {
    return {
      // 现状图加载
      loadingIframe: false,
      // 现状图显示关闭
      mapIframeVisible: false,
      // 显示四个输入框
      showThreeFlag: false,
      // 是否为缺失遗漏点
      isMissingReclaimPoint: 'NO',
      // 审定规模与送审规模是否一致
      isIdenticalScale: 'NO',
      // 地图图层模式
      mapMode: 'yx', // yx影像；sl矢量
      // 地图弹层
      mapPopup: null,
      // 地图配置
      mapBaseConfig: {
        center: [29.57, 106.55],
        // zoom: 10,
        // minZoom: 0,
        // maxZoom: 17,
        zoom: 1,
        minZoom: 0,
        maxZoom: 10,

        crs: L.CRS.EPSG4326
      },
      mapCrs: new L.Proj.CRS(
        'EPSG:4490',
        '+proj=longlat +ellps=GRS80 +no_defs ',
        {
          resolutions: [
            0.00951784402332112,
            0.006662490816324785,
            0.00237946100583028,
            0.00118973050291514,
            5.9486525145757e-4,
            2.3794610058302802e-4,
            1.1897305029151401e-4,
            5.9486525145757005e-5,
            2.3794610058302804e-5,
            1.1897305029151402e-5,
            4.75892201166056e-6
          ],
          origin: [-400.0, 399.9999999999998]
        }
      ),
      mapOptions: {
        zoomControl: false
      },
      // 地图图层
      mapLayers: {
        // 矢量
        cqVec: esri.tiledMapLayer({
          url:
            'http://www.digitalcq.com/tianditu/hlvdl/765c64c33a9d4beeae5c5329da6caebf'
        }),
        // 影像
        cqImg: esri.tiledMapLayer({
          url:
            'http://10.10.6.7:8000/tcloud/rest/services/YGYX2016_2000/MapServer?access_token=AT-41-VFSwcRcqwB-rDTSL-xLLbASLZ84Axz1D'
          // "http://www.digitalcq.com/tianditu/kxrgo/ca295a0983c5473a825b1e4700adb81b"
          // 'http://222.178.223.250:2136/arcgis/rest/services/tdzz/CQ_img/MapServer'
        }),
        // 影像注记
        cqMark: esri.tiledMapLayer({
          url:
            'http://www.digitalcq.com/tianditu/ewfwz/ff74349b1483497d913ec396ee35065b'
        })
      },
      // geoJson style
      polygonStyleMap: {
        defaultStyle: {
          color: '#ff0000',
          weight: 1,
          fillOpacity: 0.2
        },
        activeStyle: {
          // color: "#ff6600",
          color: '#ff6600',
          weight: 2,
          fillOpacity: 0.2
        }
      },

      // 地图导航配置
      defaultProps: {
        children: 'children',
        label: 'label'
      },
      // 地图导航数据
      treeData: [
        {
          id: 1,
          label: '土地利用规划',
          disabled: true,
          children: [
            {
              id: 5,
              label: '总体规划',
              disabled: true,
              isChecked: false
            },
            {
              id: 6,
              label: '管理区规划',
              disabled: true,
              isChecked: false
            },
            {
              id: 7,
              label: '土地整治规划',
              disabled: true,
              isChecked: false
            }
          ]
        },
        {
          id: 2,
          label: '城市规划',
          disabled: true,
          children: [
            {
              id: 16,
              label: '用地规划',
              disabled: true,
              isChecked: false
            },
            {
              id: 17,
              label: '控规用地规划',
              disabled: true,
              isChecked: false
            },
            {
              id: 18,
              label: '总规深化用地规划',
              disabled: true,
              isChecked: false
            }
          ]
        },
        {
          id: 3,
          label: '土地利用现状',
          children: [
            {
              id: 8,
              label: '2018年',
              url: esri.tiledMapLayer({
                url:
                  'http://10.10.6.7:8000/tcloud/rest/services/2018tdlyxz_2000/MapServer?access_token=AT-41-VFSwcRcqwB-rDTSL-xLLbASLZ84Axz1D'
              }),
              isChecked: false
            },
            {
              id: 9,
              label: '2017年',
              // disabled: true,
              url: esri.tiledMapLayer({
                url:
                  'http://222.178.223.250:2136/arcgis/rest/services/tdzz/LXZ_tdly/MapServer'
              }),
              isChecked: false
            },
            {
              id: 10,
              label: '2016年',
              disabled: true,
              isChecked: false
            },
            {
              id: 11,
              label: '2015年',
              disabled: true,
              isChecked: false
            }
          ]
        },
        {
          id: 4,
          label: '年度变更影像',
          children: [
            {
              id: 12,
              label: '2018年',
              // disabled: true,
              url: esri.tiledMapLayer({
                url:
                  // "http://222.178.223.250:2136/arcgis/rest/services/tdzz/LXZ_img/MapServer"
                  'http://10.10.6.7:8000/tcloud/rest/services/CQYX2018_2000/MapServer?access_token=AT-41-VFSwcRcqwB-rDTSL-xLLbASLZ84Axz1D'
              }),
              isChecked: false
            },
            {
              id: 13,
              label: '2017年',
              url: esri.tiledMapLayer({
                url:
                  'http://www.digitalcq.com/tianditu/dsrqc/c54e73a8bdd441b495ee531110f8086b'
              }),
              isChecked: false
            },
            {
              id: 14,
              label: '2016年',
              url: esri.tiledMapLayer({
                url:
                  'http://www.digitalcq.com/tianditu/pzosy/a0abcb4bb7db466e973cbd8867b47fe6'
              }),
              isChecked: false
            },
            {
              id: 15,
              label: '2015年',
              url: esri.tiledMapLayer({
                url:
                  'http://www.digitalcq.com/tianditu/hrjvz/6691ab289e6745feaa6580c630afe945'
              }),
              isChecked: false
            }
          ]
        }
      ],

      // 页面参数
      navActive: true,
      polygonArr: [],
      polygonMap: {},
      geoJsonArr: [],
      geoJsonOptions: {},
      baseInfoData: null, // 基本信息数据
      jgInfoData: {
        // 监管信息数据
        xctk: null, // 现场踏勘
        xctkList: [],
        qqch: null, // 前期测绘
        qqchList: [],
        cgcs: null // 成果初审
      },
      jgInfoTabActiveName: 'xctk',
      jgInfoLoading: false,
      dialogVisible: false,
      dialogImageUrl: null,
      treeCheckedObj: {},
      control: {
        lineMeasure: null,
        areaMeasure: null,
        browserPrint: null,
        siderCompare: null
      },
      fullScreen: new QScreenSwitcher(),
      isFullScreen: false,

      isFalse: true,
      sideBySidePopup: false, // 卷帘对比选择弹窗
      sideBySideStatus: 'close',
      sideBySideUrl: {
        left: null,
        right: null
      },
      markerLatLng: null,
      searchValue: '', // 搜索值
      collapseValue: '1', // 折叠面板
      toolsValue: {
        // 地图工具开关状态
        layer: false,
        ruler: false,
        area: false,
        cut: false
      },
      currentPolygon: null,
      currentPkData: null, // 当前选中片块
      popupActiveName: 'jbxx'
    }
  },
  watch: {
    xianZhuangPath(val) {
      const that = this
      this.loadingIframe = true
      this.$nextTick(() => {
        var downFrame = document.getElementById('mapIframe')
        downFrame.onload = function(e) {
          that.loadingIframe = false
        }
      })
    },
    pkList() {
      // 监听片块列表变化
      this.pkList.forEach((item, index) => {
        item['value'] = item.pkh || item.pkm || item.landName
        item['index'] = index
      })
      this.initMap()
    }
  },
  created(){
    console.log(this.showSjsc,"showSjsc")
  },
  methods: {
    // 关闭显示现状图的iframe
    closeMapIframe() {
      this.mapIframeVisible = false
    },
    handleFullScreen() {
      // 全屏
      if (this.isFullScreen) {
        this.fullScreen.exitFullScreen(document.getElementById('map-container'))
      } else {
        this.fullScreen.enterFullScreen(
          document.getElementById('map-container')
        )
      }
      // if (this.isFullScreen) {
      //   this.fullScreen.exitFullScreen(this.$refs.map.$el);
      // } else {
      //   this.fullScreen.enterFullScreen(this.$refs.map.$el);
      // }
      this.isFullScreen = !this.isFullScreen
    },
    handleClear() {
      // 清除测距、面积测距
      const _lineMeasureLayer = this.control['lineMeasure']['_layerPaint']
      const _areaMeasureLayer = this.control['areaMeasure']['_layer']
      if (_areaMeasureLayer != null) {
        for (var k in _areaMeasureLayer['_layers']) {
          _areaMeasureLayer.removeLayer(_areaMeasureLayer['_layers'][k])
        }
      }
      if (_lineMeasureLayer != null) {
        _lineMeasureLayer.clearLayers()
      }

      this.toolsValue['ruler'] = false
      this.toolsValue['area'] = false
    },
    openSideBySidePopup() {
      if (this.sideBySideStatus === 'close') {
        this.sideBySidePopup = true
      } else {
        this.handleToolsSwitch('cut')
        this.$refs.map.mapObject.removeLayer(this.sideBySideUrl.left)
        this.$refs.map.mapObject.removeLayer(this.sideBySideUrl.right)
        this.control.siderCompare.remove()
        this.sideBySideStatus = 'close'
      }
    },
    handleSideBySideClick(e, name) {
      if (e.url) {
        this.sideBySideUrl[name] = e.url
      } else {
        this.sideBySideUrl[name] = null
        this.$message({
          message: `${name === 'left' ? '左侧' : '右侧'}所选图层暂无数据`,
          type: 'warning'
        })
      }
    },
    handleSideBySide() {
      // 卷帘对比
      if (this.sideBySideUrl.left == null) {
        this.$message({
          message: `左侧所选图层暂无数据`,
          type: 'warning'
        })
        return
      }
      if (this.sideBySideUrl.right == null) {
        this.$message({
          message: `右侧所选图层暂无数据`,
          type: 'warning'
        })
        return
      }
      const left = this.sideBySideUrl.left
      const right = this.sideBySideUrl.right
      this.$refs.map.mapObject.addLayer(left)
      this.$refs.map.mapObject.addLayer(right)
      this.control.siderCompare = L.control
        .sideBySide(left, right)
        .addTo(this.$refs.map.mapObject)
      this.sideBySidePopup = false
      this.sideBySideStatus = 'open'
      this.handleToolsSwitch('cut')
    },
    initMap() {
      this.$nextTick(() => {
        const _geoJsonArr = []
        this.$refs.geoJson.forEach((item, index) => {
          _geoJsonArr.push(item.getBounds())
        })
        this.geoJsonArr = _geoJsonArr
        this.$refs.map.fitBounds(this.geoJsonArr) // 定位到图形位置

        if (
          this.isShowControls == false &&
          this.zhjgList &&
          this.zhjgList.length > 0
        ) {
          this.zhjgList.forEach(item => {
            if (item.coorDonate) {
              let arr = item.coorDonate.split(',')
              L.marker([arr[1], arr[0]]).addTo(this.$refs.map.mapObject)
            }
          })
        }

        // 加载测距、面积测距、打印控件
        this.control.lineMeasure = L.control
          .lineMeasure({ drawBtn: document.getElementById('lineMeasure') })
          .addTo(this.$refs.map.mapObject)
        this.control.areaMeasure = L.control
          .areaMeasure({ drawBtn: document.getElementById('areaMeasure') })
          .addTo(this.$refs.map.mapObject)
        this.control.browserPrint = L.control
          .browserPrint({ el: document.getElementById('browserPrint') })
          .addTo(this.$refs.map.mapObject)
      })
    },
    changeMapMode(mode) {
      // 切换地图模式
      this.mapMode = mode
    },
    handleClickPolygon(e, item, index) {
      // 点击多边形开启片块详情popup
      this.$parent.getCurListIndex(index)
      this.baseInfoData = item
      this.$nextTick(() => {
        this.$refs.features.mapObject.openPopup([e.latlng.lat, e.latlng.lng])
      })

      this.currentPkData = item
      this.popupActiveName = 'jbxx'
      // this.handleScView(this.currentPkData)
    },
    changePkPosition(index) {
      // 点击
      this.restorePolygonStyle()
      this.currentPolygon = this.$refs.geoJson[index]
      this.currentPolygon.setOptionsStyle(this.polygonStyleMap.activeStyle)
      this.$refs.map.fitBounds(this.currentPolygon.getBounds())
    },
    restorePolygonStyle() {
      // 重置地图片块样式
      this.$refs.geoJson.forEach((item, index) => {
        item.setOptionsStyle(this.polygonStyleMap.defaultStyle)
      })
    },
    handleImageDialog(url) {
      this.dialogImageUrl = url
      this.dialogVisible = true
    },
    handleTreeCheck(item) {
      if (item.disabled) {
        this.$message({
          message: `暂无图层`,
          type: 'warning'
        })
        return
      }
      if (item.url) {
        item.isChecked = !item.isChecked
        if (item.isChecked == true) {
          this.treeCheckedObj[item.id] = item.url
        } else {
          delete this.treeCheckedObj[item.id]
        }
      }
      this.$forceUpdate()
    },
    handlePkSearch(queryString, callback) {
      var restaurants = this.pkList
      var results = queryString
        ? restaurants.filter(this.createFilter(queryString))
        : restaurants
      callback(results)
    },
    createFilter(queryString) {
      return restaurant => {
        return (
          restaurant.value.toLowerCase().indexOf(queryString.toLowerCase()) ===
          0
        )
      }
    },

    handleMapSearchSelect(item) {
      this.currentPkData = item
      // this.handleScView(this.currentPkData)
      this.changePkPosition(item.index)
    },
    handleToolsSwitch(name) {
      this.toolsValue[name] = !this.toolsValue[name]
    },
    handleXzView() {
      this.mapIframeVisible = true
      this.$parent.toSeeXianZhuang(this.currentPkData)
    },
    handleAutocompleteClear() {
      this.restorePolygonStyle()
      this.currentPkData = null
      this.$refs.map.fitBounds(this.geoJsonArr) // 定位到图形位置
    },
    handleScView(value) {
      this.$parent.shenchaWy(this.currentPkData)
    },
    handleCheckOpinion(obj) {
      // 意见校验
      const loadingInstance = this.$loading(this.$loadingData)
      verify_drawings_opinion({
        process: localStorage.getItem('router'),
        projectId: localStorage.getItem('projectId'),
        stage: obj.stage
      })
        .then(res => {
          loadingInstance.close()
          this.$alert('当前流程办理完成', '提示', {
            confirmButtonText: '确定',
            callback: action => {
              this.$router.push({
                path: obj.path
              })
            }
          })
        })
        .catch(() => {
          loadingInstance.close()
        })
    },
    handleExportOpinion() {
      var linkName = ''
      if(this.fsLinkValue){
        linkName = this.fsLinkValue
      }else{
        linkName = this.linkValue
      }
      // 导出意见
      let _url = this.$https
      _url += '/pc/project/early_mapping_result/first_audit/land/opinion_review'
      _url += '?projectId=' + localStorage.getItem('projectId')
      _url += '&linkId=' + linkName
      window.open(_url)
    }
  }
}
</script>

<style lang="scss" scoped>
$popup-height: 450px;

.map-container {
  position: relative;
  display: flex;
  justify-content: center;
  // height: calc(100vh - 200px);
  height: 100%;
  // margin-top: 30px;
  // margin-bottom: 30px;
}
.map-left {
  width: 0;
  border: 1px solid #e9e9e9;
  border-right: none;

  &.active {
    width: 230px;
  }
}
.map-nav {
  background: #f2f2f2;
  height: 40px;
  border-bottom: 1px solid #e9e9e9;
  overflow: hidden;
  text-align: center;
  font-size: 16px;
  font-weight: bold;
  color: #4d4d4d;
  line-height: 40px;
}
.map-right {
  width: 100%;
}
.map-mode {
  display: flex;
  flex-direction: row;
  width: auto;
  height: 62px;
  overflow: hidden;
  font-size: 0;
  position: absolute;
  z-index: 500;
  right: 0;
  bottom: 30px;

  &-item {
    position: relative;
    width: 62px;
    height: 62px;
    display: block;
    overflow: hidden;
    border: 1px solid #308be7;
    margin-right: 10px;
    cursor: pointer;

    .text {
      background: rgba(0, 0, 0, 0.5);
      width: 100%;
      height: 20px;
      display: block;
      overflow: hidden;
      font-size: 13px;
      color: #fff;
      text-align: center;
      line-height: 20px;
      position: absolute;
      left: 0;
      bottom: 0;
      z-index: 1;
    }
  }

  &-item.yx {
    background: url('../../assets/map/type-img-icon.png');
    background-repeat: no-repeat;
    background-size: cover;
  }

  &-item.sl {
    background: url('../../assets/map/type-vector-icon.png');
    background-repeat: no-repeat;
    background-size: cover;
  }
}

.nav-switch {
  position: absolute;
  top: 50%;
  left: 0;
  transform: translateY(-50%);
  background: #fff;
  width: 20px;
  height: 30px;
  border: 1px solid #ccc;
  border-left: 0 none;
  display: block;
  overflow: hidden;
  font-size: 18px;
  text-align: center;
  line-height: 30px;
  position: absolute;
  z-index: 1001;
  border-radius: 0 5px 5px 0;
  cursor: pointer;
}

.map-tools {
  width: auto;
  height: 40px;
  border-radius: 4px;
  box-shadow: 1px 1px 2px #666;
  overflow: hidden;
  font-size: 0;
  position: absolute;
  z-index: 500;
  right: 30px;
  top: 30px;
  cursor: pointer;

  &-item {
    position: relative;
    float: left;
    background: #fff;
    // width: 40px;
    padding: 0 12px;
    // border-bottom: 1px solid #efefef;
    overflow: hidden;
    line-height: 40px;
    font-size: 0;
    color: #666;
    text-align: center;
    // border-right: 1px solid #e6e6e6;

    &.line:after {
      position: absolute;
      display: block;
      content: '';
      top: 50%;
      transform: translateY(-50%);
      left: 0;
      width: 1px;
      height: 18px;
      background: rgba(230, 230, 230, 1);
    }

    i {
      color: #666;
      display: block;
    }

    .svg-icon {
      display: block;
      font-size: 24px;
      height: 40px;
      color: #666;
    }

    &.active {
      i {
        color: #409eff;
      }
    }

    &:hover {
      background: #efefef;
    }
  }
}

.map-search {
  position: absolute;
  z-index: 500;
  left: 30px;
  top: 30px;
  font-size: 0;
  display: flex;
  flex-direction: row;

  .line:after {
    position: absolute;
    display: block;
    content: '';
    top: 50%;
    transform: translateY(-50%);
    left: 0;
    width: 1px;
    height: 18px;
    background: rgba(230, 230, 230, 1);
  }

  /deep/ .el-button-group {
    position: relative;
    margin-left: 10px;
    border-radius: 4px;
    box-shadow: 1px 1px 2px #666;
  }

  /deep/ .el-button {
    border: 1px solid #fff;
  }

  /deep/ .el-input__inner {
    width: 344px;
    border-radius: 4px;
    box-shadow: 1px 1px 2px #666;
  }

  /deep/ .el-input__inner {
    height: 36px;
    border: none;
  }

  /deep/ .el-input__icon {
    font-size: 18px;
    line-height: 36px;
    color: #999;
  }

  ::-webkit-input-placeholder {
    /* WebKit browsers */
    color: #b3b3b3;
    font-size: 14px;
  }

  ::-moz-placeholder {
    /* Mozilla Firefox 19+ */
    color: #b3b3b3;
    font-size: 14px;
  }

  :-ms-input-placeholder {
    /* Internet Explorer 10+ */
    color: #b3b3b3;
    font-size: 14px;
  }
}

.map-layer {
  width: 392px;
  position: absolute;
  z-index: 1001;
  right: 30px;
  top: 86px;
  border-radius: 4px;
  overflow: hidden;
  box-shadow: 1px 1px 2px #666;

  /deep/ .el-collapse-item__header {
    // background-color: #f5f5f5;
    height: 40px;
    line-height: 40px;
    box-shadow: 0px 3px 6px rgba(0, 0, 0, 0.2);
  }

  /deep/ .el-collapse-item__wrap {
    background-color: rgba(255, 255, 255, 0.8);
  }

  /deep/ .el-collapse-item__arrow {
    margin: 0 18px 0 auto;
  }

  &-title {
    position: relative;
    font-size: 16px;
    font-family: PingFang SC;
    font-weight: 500;
    color: rgba(77, 77, 77, 1);
    margin-left: 28px;

    &::before {
      content: '';
      position: absolute;
      display: block;
      width: 3px;
      height: 16px;
      background: rgba(21, 112, 213, 1);
      top: 50%;
      left: -8px;
      transform: translateY(-50%);
    }
  }

  /deep/ .el-collapse-item__content {
    padding-bottom: 0;
  }

  &-content {
    display: flex;
    flex-wrap: wrap;
    padding: 20px;

    &-item {
      font-size: 15px;
      font-family: PingFang SC;
      font-weight: 500;
      color: rgba(102, 102, 102, 1);
      margin-right: 24px;
      transition: all 0.3s;
      cursor: pointer;

      &:hover {
        color: #409eff;
      }

      &.active {
        color: #409eff;
      }
    }
  }
}

.leaflet-control-browser-print {
  display: none;
}

.side-by-side-popup {
  text-align: center;

  .confirm-btn {
    margin-top: 26px;
  }

  /deep/
    .el-tree--highlight-current
    .el-tree-node.is-current
    > .el-tree-node__content {
    // background-color: #f9b5a3;
    background-color: rgb(160, 207, 255);
  }
}

/* popup s */

.pk-popup-box {
  display: flex;
  flex-direction: row;
  align-items: center;
  height: 50px;
  line-height: 50px;
  border-bottom: 1px solid #f7f8fa;

  .left {
    width: 88px;
    height: 100%;
    background-color: #f7f8fa;
    border-radius: 4px;
  }

  .pk-popup-title {
    font-size: 15px;
    color: #999;
    padding-left: 10px;
  }
}

/deep/ .leaflet-popup-content {
  margin: 0;
  padding: 0;
}

/deep/ .leaflet-popup-content-wrapper {
  box-shadow: 0px 3px 6px rgba(0, 0, 0, 0.16);
  border-radius: 4px;
  padding: 0;
}

/deep/ .leaflet-popup-tip {
  box-shadow: 0px 3px 6px rgba(0, 0, 0, 0.16);
}

.pk-popup-tabs {
  height: $popup-height;

  /deep/ .el-tabs--border-card {
    border: none;
  }

  /deep/ .el-tabs__nav-scroll {
    background-color: #f7f8fa;
    border-radius: 4px;
  }

  /deep/ .el-tabs__item {
    padding: 0;
    width: 88px;
    color: #999;
  }

  /deep/ .el-tabs__nav-wrap::after {
    background-color: #f7f8fa;
  }

  /deep/ .el-tabs__item:hover {
    color: #409eff;
  }

  /deep/ .el-tabs__item.is-active {
    color: #409eff;
    background-color: #ebeff5;
  }
}

/deep/ .el-tabs--left .el-tabs__header.is-left {
  margin-right: 0;
}

/deep/ .el-tabs--left .el-tabs__item.is-left {
  text-align: center !important;
}

/deep/ .leaflet-container a.leaflet-popup-close-button {
  top: 10px;
  right: 10px;
}

/deep/ .base-info {
  height: $popup-height - 10px;
  overflow-x: hidden;
  overflow-y: auto;

  .tableBasicInfo {
    font-size: 16px;
    text-align: left;
    width: 100%;
    box-sizing: border-box;
    border: 1px solid #ebeef5;
    border-bottom: 0px;

    span {
      color: #666666;
    }

    .redText {
      color: red;
    }
  }

  .tableBasicInfo tr th,
  .tableBasicInfo tr td {
    border-bottom: 1px solid #ebeef5;
    padding: 8px 10px;
  }

  .tableBasicInfo tr th {
    font-weight: normal;
    border-right: 1px solid #ebeef5;
    color: #b3b3b3;
  }

  .tableBasicInfo tr td {
    color: #666;
  }

  &.jbxx {
    padding: 10px;
  }

  &.jgxx {
    padding: 20px;

    .ziliaoList {
      overflow-x: hidden;
      overflow-y: auto;
      padding: 0;
      margin: 0;

      li {
        float: left;
        font-size: 14px;
        color: #1d88f3;
        margin-right: 18px;
        cursor: pointer;
        margin-bottom: 8px;
      }
    }
  }

  &.sjsc {
    padding: 20px;
  }
}

/* popup e */

.yijianBox-item {
  margin-bottom: 20px;
  font-size: 14px;
  color: #666666;
  display: flex;

  .yijianBox-item-left {
    margin-right: 30px;
  }
}

.jibenxinxiyijian {
  margin-top: 33px;
  margin-left: 10px;
}

.submityijian {
  margin-top: 60px;
}

.iframeLoad {
  display: flex;
  font-size: 35px;
  width: 100%;
  height: 100%;
  align-items: center;
  justify-content: center;
}

.map-iframe {
  opacity: 0.5;
  position: absolute;
  top: 0;
  right: 0;
  z-index: 501;
  width: 50%;
  height: 100%;
  box-sizing: border-box;
  padding-top: 40px;
  background-color: #fff;

  .shenchaButton {
    position: absolute;
    top: 10px;
    right: 10px;
  }
}

.map-iframe:hover {
  opacity: 1;
}

.shenchaBox {
  margin-top: 20px;
  display: flex;
  justify-content: center;
  margin-bottom: 20px;
}

.shenchaBox_item_input {
  width: 300px;
}

.shenchaBox_item_button {
  width: 300px;
  display: flex;
  justify-content: center;
  margin-top: 20px;
  margin-bottom: 50px;
}

.shenchaBoxDialog /deep/ .el-dialog {
  width: 500px;
}

.buttonGroupClass {
  display: flex;
}
</style>
